﻿namespace Innovative.ProXr
{
	/// <summary>
	/// Converts an API that responds with 85 to indicate success
	/// to a Boolean value.
	/// </summary>
	public class Boolean85ResponseConverter : IResponseConverter<bool>
	{
		bool IResponseConverter<bool>.Convert(RelayByte[] response)
		{
			bool returnValue = false;

			if (response.Length == 1)
			{
				returnValue = (response[0] == 85);
			}
			else
			{
				throw new InvalidResponseException("The BooleanResponseConverter converter expects a single byte response.");
			}

			return returnValue;
		}
	}
}
